package com.sparrow.common.packet;

import java.lang.reflect.Method;

public class ReflectPacketInvoker implements PacketInvoker {

    private final Object object;
    private final Method method;

    public ReflectPacketInvoker(Object object, Method method) {
        this.object = object;
        this.method = method;
    }

    public Method getMethod() {
        return method;
    }

    public Object getObject() {
        return object;
    }

    public void invoke(Object[] args) {
        try {
            method.invoke(object, args);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
